package day03;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Scanner;

/**2018-03-25
 * 输入一个生产日期格式"yyyy-MM-dd",再输入一个数字(保质期的天数)。
 * 然后经过计算输出促销日期，促销日期为:该商日品过期前2周的周三
 * @author Bonnie
 * 
 */
public class Test04 {
    public static void main(String[] args) throws ParseException {
        System.out.println("请输入一个生产日期格式\"yyyy-MM-dd\"：");
        System.out.println("请再输入一个数字(保质期的天数):");
        Scanner console = new Scanner(System.in);
        String date = console.nextLine();
        int expiration_date = console.nextInt();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-mm-dd");
        Date time = sdf.parse(date);
        Calendar cal = Calendar.getInstance();
        cal.setTime(time);
        cal.add(Calendar.DAY_OF_YEAR,expiration_date);
        cal.add(Calendar.DAY_OF_YEAR,-14);
        cal.set(Calendar.DAY_OF_WEEK,4);
        Date saleTime = cal.getTime();
        System.out.println(sdf.format(saleTime));
    }
}
